package oo

import (
	"elegantGo/chapter04/pkg/validate"
	"github.com/elliotchance/pie/v2"
	"strings"
)

type Substring struct {
	String
}

func (o *Substring) IsIntsValid() bool {
	return validate.Var(o.split(), "min=1,unique,dive,int") == nil
}

func (o *Substring) Ints() []int {
	return pie.Ints(o.split())
}

func (o *Substring) split() []string {
	return strings.Split(o.value, ",")
}
